<template>
	<view style="padding: 30rpx;">
		<view>异步接口</view>
		<button @click="">setStorage</button>
		<button @click="" type="primary" plain="true">getStorage</button>
		<button @click="" type="primary">getStorageInfo</button>
		<button @click="" type="warn" plain="true">RemoveStorage</button>
		<button @click="" type="warn">clearStorage</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:"zhixin",
				timer1:null,
			}
		},
		methods: {
			callStorageFun(parm){
				console.log("callStorageFun==> parm " + parm);
				switch(parm){
				  case 1:
					// 存某一个字段到本地 字段名：值
					uni.setStorage({
						key:'PassWord',
						data:'zx',
						success(){
							console.log("UserName 存储成功");
						}
					});
					console.log("调用存储完成");
					break;
				  case 2:
					uni.getStorage({
						key:'Username',
						// 回调接口
						success(){
							console.log("读取UserName 存储成功 result.data="+ result.data);
						},
						fail(){
							console.error("读取UserName 存储失败");
						}
					})
					break;
					case 3:
					  uni.getStorageInfo({
						  success:function(result){
							  console.log("获取所有缓存字段: "+ result.keys);
						  	
						  }
					  })
					break;
					case 4:
					uni.removeStorage({
						key:'Username',
						success(){
						console.log("Username 删除成功 ");
						}
					})
					break;
				}
			}
		}
	}
</script>

<style>
button{
	margin: 30rpx;
}
</style>
